package com.xbs.controller.enterprise;



import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xbs.controller.base.BaseServlet;
import com.xbs.entity.EpOptionEitity;
import com.xbs.entity.EpOptionOrderQueryEntity;
import com.xbs.service.enterprise.EpOptionOrderService;
import com.xbs.utils.PageUtilEntity;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
import net.sf.json.util.CycleDetectionStrategy;

@WebServlet("/enterprise/ordermanager/optionquery")
public class EpOtionOrderQueryController extends BaseServlet{
		@Override
		protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
			doPost(req,resp);
		}
		@Override
		protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
				PrintWriter out=resp.getWriter();
				String startTime=req.getParameter("startTime");
				String endTime=req.getParameter("endTime");
				String status=req.getParameter("status");
				Integer curr=Integer.parseInt(req.getParameter("curr"));
				Integer size=Integer.parseInt(req.getParameter("size"));
				EpOptionOrderQueryEntity query=new EpOptionOrderQueryEntity();
				query.setStatus(status);
				query.setEndTime(endTime);
				query.setStartTime(startTime);
				EpOptionOrderService service=new EpOptionOrderService();
				PageUtilEntity<EpOptionEitity> page=service.getEpOrderOption(query, curr, size);
				
				JsonConfig jsonConfig = new JsonConfig();   
				jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);   
				jsonConfig.registerJsonBeanProcessor(java.sql.Date.class, new DateJsonValueProcessor());  
				jsonConfig.setExcludes(new String[]{"handler","hibernateLazyInitializer"});    
				/*JSONArray.fromObject(list,jsonConfig);  */
				//JSONArray jsonArray = JSONArray.fromObject(page.getIst(),jsonConfig);
				JSONObject obj =JSONObject.fromObject(page,jsonConfig);
				
				out.println(obj.toString());
				
				
				
				
			
		}
}
